<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    
    <title>My JSP 'IndustryManager.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/biaoge.css"/>
	<link rel="stylesheet" type="text/css" href="fancybox/jquery.fancybox-1.3.4.css"/>
	  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
	 <script type="text/javascript" src="jquery/js/jquery-1.8.2.js"></script> 
	 <script type="text/javascript" src="jquery/js/jquery-ui-1.9.0.custom.min.js"></script> 
     <script type="text/javascript" src="fancybox/jquery.easing-1.3.pack.js"></script> 
	<script type="text/javascript" src="fancybox/jquery.fancybox-1.3.4.js"></script> 
	<script type="text/javascript" src="fancybox/jquery.fancybox-1.3.4.pack.js"></script> 
	<script type="text/javascript" src="fancybox/jquery.mousewheel-3.0.4.pack.js"></script> 
     <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
      <script type="text/javascript" src="js/JTimer_2.0.js"></script>
  <style type="text/css">
    .td{text-align: center;}
  </style>
  </head>
  <script type="text/javascript">
  
   function fangda(tupian){
   $("#"+tupian+"k").fancybox();
  }
  
  function riqichaxun(){
  var datetime=$("#riqi").val();
  var yonghu=$("#uname").val();
  var sele=$("#sele").val();
  var indusid=$("#indusid").val();
   window.location="selecteveryindusByMany?indusid="+indusid+"&&datetime="+datetime+"&&uname="+yonghu+"&&orderstate="+sele;
  }
  
  $(document).ready(function() {
		$("#dio").dialog({
			autoOpen : false,
			module : true,
			/* buttons : {
				确定 : function() {
				    // alert("aaa");
					$(this).dialog("close");
					
					}
			},  */
			closeOnEscape : true,//点击键盘ESC键关闭dialog
			hide : "fadeout",//关闭特效
			modal : true,//蒙层（弹出会影响页面大小）
			title : "说明理由",
			overlay : {//覆盖层
				opacity : 0.5,//不透明度
				background : "black",
				overflow : 'auto'//内容溢出元素框事件
			}
		});
	});
	 $(document).ready(function() {
		$("#fandio").dialog({
			autoOpen : false,
			module : true,
			/* buttons : {
				确定 : function() {
				    // alert("aaa");
					$(this).dialog("close");
					
					}
			},  */
			closeOnEscape : true,//点击键盘ESC键关闭dialog
			hide : "fadeout",//关闭特效
			modal : true,//蒙层（弹出会影响页面大小）
			title : "说明理由",
			overlay : {//覆盖层
				opacity : 0.5,//不透明度
				background : "black",
				overflow : 'auto'//内容溢出元素框事件
			}
		});
	});
	function dakai(id) {
	   // var k='<input type="hidden" id="order"'+' '+'value='+id+'>';
	   var k=document.createElement("input");
	       k.type="hidden";
           k.id="order";
	       k.value=id;
	    alert("qian"+id+k);
	   //// var kk=document.createElement("hidden");
	   // kk.attributes("value",id);
	   // kk.attributes("name","order");
	 //document.getElementById("dio").innerHTML+=k;
	 document.getElementById("dio").appendChild(k);
		$("#dio").dialog("open");
		  
	}
	
  function fandakai(id) {
	   // var k='<input type="hidden" id="order"'+' '+'value='+id+'>';
	   var k=document.createElement("input");
	       k.type="hidden";
           k.id="fanorder";
	       k.value=id;
	    alert("qian"+id+k);
	   //// var kk=document.createElement("hidden");
	   // kk.attributes("value",id);
	   // kk.attributes("name","order");
	 //document.getElementById("dio").innerHTML+=k;
	 document.getElementById("fandio").appendChild(k);
		$("#fandio").dialog("open");
		  
	}
	
   function gaibian(){
   var you=$("#liyou").val().trim();
   if(you!=""&&you!=null)
    document.getElementById("queding").disabled=false;
   else
   document.getElementById("queding").disabled=true;
   }
   
    function gaianniu(){
   var you=$("#yuanyin").val().trim();
   if(you!=""&&you!=null)
    document.getElementById("que").disabled=false;
   else
   document.getElementById("que").disabled=true;
   }
   
   function quehuo(){
   
  var you=$("#liyou").val().trim();
  var id=$("#order").val();
  $("#order").remove();
 alert("hou:"+id);
       $.post(
       "stockoutReason",
       {orderid:id,liyou:you},
       function(data){
        document.getElementById("liyou").value="";
        alert("缺货理由已经提交");
        $("#dio").dialog("close");
       },"json"
       );
   }
   
    function updateordertstate(id){ 
   $.post(
				"updateOrderstate.action",
				{orderid:id},  
      		function(data){
      		 //$("#"+id+"").html("已发货");
      		 var k='<font color="blue">已发货</font>';
      		 alert(k);
      		 document.getElementById(id).innerHTML=k;
      		}, "json"
      		);
      		
    }
    
    function fankui(){
       var you=$("#yuanyin").val().trim();
       var id=$("#fanorder").val();
       $("#fanorder").remove();
       alert("hou:"+id);
       $.post(
       "feedbackReason.action",
       {orderid:id,yuanyin:you},
       function(data){
        document.getElementById("yuanyin").value="";
        alert("反馈理由已经提交");
        $("#fandio").dialog("close");
       },"json"
       );
    }
    
   function xiazai(name,id){

     var orid=id+"m";
    alert(name+"  "+orid);
    var url=document.getElementById(orid).value;
    var arr=url.split("\\");
    alert(arr[arr.length-1]); 
    window.location="downloadCDR?username="+name+"&&fileName="+arr[arr.length-1]; 
  }
  </script>
  <body>
          
 
         <div  style="margin-left:150px;margin-top:20px">
         
       <div style="float:right;margin-top:-70px">订单查询：
       输入日期：<input type="text" name="riqi" id="riqi" onclick="JTC.setday({format:'yyyy-MM-dd', readOnly: true})">输入用户名：<input type="text" id="uname">订单状态
       <select id="sele">
       <option value="0"></option>
       <option value="1">未发货</option>
       <option value="2">已发货</option>
       </select>
       <input type="button" value="查询" onclick="riqichaxun()">
       </div>
       
       <input type="hidden" value="${mana.industryId}" id="indusid">
       
       <div style="margin-left:150px;margin-top: 80px">
       <font size="5" color="red">今天的订单如下</font> 
       <table id="mytable" cellspacing="3">
     <tr>
      <td>订单图片</td><td>用户名称</td> <td>订单名称</td><td>下单时间</td> <td>定制数量</td><td>用户地址</td><td> 用户电话</td><td>使用快递</td><td>订单状态</td><td>下载CDR文件</td><td>是否能够发货</td></tr>
       <c:forEach items="${orderlist}" var="order">
       <c:if test="${!empty order.userName}">
       <tr class="td">
      
     <td><img src="${order.orderPic}" style="height:76px;width:100px""/>
   <a id="${order.orderId}k" href="${order.orderPic}"><img src="img/fangda.gif" onclick="fangda('${order.orderId}')" style="float: right;"></a></td>
     <td>${order.userName}</td><td>${order.orderName}</td><td><fmt:formatDate value="${order.orderTime}" pattern="yyyy-MM-dd" /></td><td>${order.orderProductsCount}</td>
       <td>${order.orderAddress}</td><td>${order.orderMobilePhone}</td><td>${order.orderFreight}</td>
      <c:choose>
       <c:when test="${order.orderState==1}">
   <td id="${order.orderId}"><font size="3" color="red">用户已付款，未发货</font></td>
   </c:when>
   <c:when test="${order.orderState==2||order.orderState==3}">
    <td><font size="3" color="blue">已发货</font></td>
    </c:when>
    </c:choose>
    <c:if test="${!empty order.CDRurl}">
    <td><input type="button" value="下载" onclick="xiazai('${order.userName}','${order.orderId}')"></td>
    </c:if>
     <c:if test="${empty order.CDRurl}">
                  <td> 没有CDR文件</td>
     </c:if>
     <if test="${order.orderState==1}">
    <td><input type="button" value="发货" onclick="updateordertstate('${order.orderId}')"><input type="button" value="缺货" onclick="dakai('${order.orderId}')"></td>
      </if>
       </tr>
       
       <input type="hidden" id="${order.orderId}m" value="${order.CDRurl}"/>
       <tr>
       <c:forEach items="${maplist}" var="mapli">
      <td colspan="2" >${mapli.labelcostname}:${mapli.labelcostmoney}</td>
      </c:forEach>
       <td><input type="button" value="反馈" onclick="fandakai('${order.orderId}')"></td> 
       </tr>
       </c:if>   
       </c:forEach>  
             </table>  
             </div>                       
     </div> 
 
       <div id="dio" >
      <textarea id="liyou" rows="10" cols="20" onkeyup="gaibian()"></textarea><br>
      <input type="button" value="确定"  disabled="disabled" id="queding" onclick="quehuo()">
     </div>    
            
        <div id="fandio">
      <textarea id="yuanyin" rows="10" cols="20" onkeyup="gaianniu()"></textarea><br>
      <input type="button" value="确定" disabled="disabled" id="que" onclick="fankui()">
     </div>                                                                                                                
  </body>
</html>
